package com.start.avue;


import com.alibaba.fastjson2.JSONObject;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
public class AvueBaseFormColumn {

    private String type = "input" ;

    @Schema(name = "表单新增时是否禁止", description = "false")
    private Boolean addDisabled = false;

    @Schema(name = "表单新增时是否可见", description = "true")
    private Boolean addDisplay = true;

    @Schema(name = "表单新增时是否可查看", description = "false")
    private Boolean addDetail = false;

    @Schema(name = "对齐方式 left/center/right 表格生效", description = "left")
    private String align = "left" ;

    @Schema(name = "表单编辑时是否禁止", description = "false")
    private Boolean editDisabled = false;
    @Schema(name = "表单编辑是否可见", description = "true")
    private Boolean editDisplay = true;
    @Schema(name = "表单编辑是否查看状态", description = "false")
    private Boolean editDetail = false;
    @Schema(name = "表单生效 列名称宽度")
    private String labelWidth;
    @Schema(name = "列名称", description = "true")
    private String label;
    @Schema(name = "字段名", description = "true")
    private String prop;
    @Schema(name = "全部是否可见", description = "true")
    private Boolean display;
    @Schema(name = "其他配置属性")
    private Map<String, Object> props;
    private Integer span = 24;
    private List dicData;

    @Schema(name = "远程数据地址")
    private String dicUrl;

    private String sqlType;

    private Integer sqlTypeDataLength;

    @Schema(name = "是否隐藏列")
    private boolean hide;

    public AvueBaseFormColumn() {

    }

    /**
     * @param label label
     * @param prop  字段名
     * @param type  前端组件类型
     */
    public AvueBaseFormColumn(String label, String prop, String type) {
        this.type = type;
        this.label = label;
        this.prop = prop;
    }


    /**
     * 构建json对象
     *
     * @return
     */
    public JSONObject toOption() {

        return JSONObject.from(this);
    }
}
